﻿using FluentValidation;
using SH.Common.DataDictionary;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SH.Multitenant.Domain.RBAC
{
    //[SugarTable("EmployeeSubTableDay_{day}_{month}_{year}")]
    //[SplitTable(SplitType.Month)]
    public class Employee : Tenant
    {
        /// <summary>
        /// 员工编号 入职时间戳
        /// </summary>

        [SugarColumn(IsPrimaryKey = true)]
        public string EmpId { get; set; }
        /// <summary>
        /// 员工账号
        /// </summary>
        [SugarColumn(ColumnDataType = "Nvarchar(20)")]
        public string? EmpName { get; set; }
        /// <summary>
        /// 员工密码
        /// </summary>
        [SugarColumn(ColumnDataType = "Nvarchar(20)")]
        public string? EmpPwd { get; set; }
        /// <summary>
        /// 手机号码
        /// </summary>
        [SugarColumn(ColumnDataType = "Nvarchar(11)")]
        public string? Tel { get; set; }
        /// <summary>
        /// 邮箱
        /// </summary>
        [SugarColumn(ColumnDataType = "Nvarchar(200)")]
        public string? Email { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        public bool Gender { get; set; }
        /// <summary>
        /// 入职时间
        /// </summary>

        //[SplitField]
        public DateTime? EntryTime { get; set; }
        /// <summary>
        /// 员工状态 1在职 2休息 3离职
        /// </summary>
        public int EmpStatus { get; set; }
        /// <summary>
        /// 门店编号
        /// </summary>
        public int StoreId { get; set; }
        /// <summary>
        /// 员工姓名
        /// </summary>
        [SugarColumn(ColumnDataType = "Nvarchar(50)")]
        public string? RealName { get; set; }
    }
    public class EmployeeValidator : AbstractValidator<Employee>
    {
        public EmployeeValidator()
        {
            RuleFor(x => x.EmpName).NotEmpty().MaximumLength(20);
            RuleFor(x => x.EmpPwd).NotEmpty().MaximumLength(20);
            RuleFor(x => x.Tel).NotEmpty().MaximumLength(11);
            RuleFor(x => x.RealName).NotEmpty().MaximumLength(50);
            RuleFor(x => x.Email).MaximumLength(200);
            RuleFor(x => x.EntryTime).NotEmpty();
            RuleFor(x => x.RealName).NotEmpty();
        }
    }
}
